//
//  LQCompanyViewController.m
//  LQProductIntelligenceService
//
//  Created by Yim on 16/5/14.
//  Copyright © 2016年 张宁. All rights reserved.
//

#import "LQCompanyViewController.h"



// 先设定btn的几个常量值
#define btnSpace 15.0
#define btnWidth 100.0
#define btnHeight  30.0
@interface LQCompanyViewController ()

@property (nonatomic , strong) NSArray *companyArray;

@end

@implementation LQCompanyViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.view.backgroundColor = LQMyViewColor;


    for (int i = 0; i < self.companyArray.count; i++) {
        UIButton *button = [[UIButton alloc] init];
        button.frame = CGRectMake(btnSpace, i * (btnHeight + btnSpace) + btnSpace, btnWidth, btnHeight);
        [button setBackgroundImage:[UIImage imageNamed:@"btn_filter_normal"] forState:UIControlStateNormal];
        [button setBackgroundImage:[UIImage imageNamed:@"btn_filter_selected"] forState:UIControlStateHighlighted];
      
        [button setTitle:@"" forState:UIControlStateNormal];
        button.titleLabel.font = [UIFont systemFontOfSize:14];
        button.tag = i;
        [button setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
        [button setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
        [button addTarget:self action:@selector(clickChooseCompany:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:button];
    }
    self.preferredContentSize = CGSizeMake(2 * btnSpace + btnWidth, self.companyArray.count * (btnSpace + btnHeight) + btnSpace);
    
}

- (void) clickChooseCompany:(UIButton *) button
{
 
    [[NSNotificationCenter defaultCenter] postNotificationName:@"changeCompanyName" object:self userInfo:@{@"LQcompany":@"",@"companyName":@""}];
    [self dismissViewControllerAnimated:YES completion:nil];
}

@end
